package mvp.com.bbc.ui.presenter;

import javax.inject.Inject;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import mvp.com.bbc.appContact.AppContact;
import mvp.com.bbc.bean.HotCoultBean;
import mvp.com.bbc.ui.model.HotCoultModel;

/**
 * Created by Administrator on 2017/9/30.
 */

public class HotCoultPresenter implements AppContact.HotCoultPresenter {
    private AppContact.HotCoultModel mCoultModel;
    private AppContact.HotCoultView mCoultView;

    @Inject
    public HotCoultPresenter(AppContact.HotCoultView coultView) {
        mCoultView = coultView;
        mCoultModel = new HotCoultModel();
    }

    @Override
    public void hotCoultPresenter(String currentPage) {
        mCoultModel.hotCoultModel(currentPage).observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Observer<HotCoultBean>() {
                    @Override
                    public void onSubscribe(@NonNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NonNull HotCoultBean hotCoultBean) {
                        mCoultView.HotCoulView(hotCoultBean);
                    }

                    @Override
                    public void onError(@NonNull Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });

    }
}
